package gb.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import gb.demo.entity.User;
import gb.demo.entity.Userdescrip;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserDescripMapper extends BaseMapper<Userdescrip> {
    @Select("select us.userid,us.labelid,ll.labelname,us.weight from userdescrip us left join label ll on us.labelid= ll.labelid where userid=#{userid} ORDER BY weight DESC")
    List<Userdescrip> findPreferenceByUserId(@Param("userid") int userid);

    @Update("UPDATE userdescrip SET weight=weight+10 WHERE userid=#{userid} AND labelid =#{labelid}")
    Boolean weightAdd(@Param("userid") int userid,@Param("labelid") int labelid);
    @Update("UPDATE userdescrip SET weight=weight+1 WHERE userid=#{userid} AND labelid =#{labelid}")
    Boolean like(@Param("userid") int userid,@Param("labelid") int labelid);
    @Update("UPDATE userdescrip SET weight=weight-10 WHERE userid=#{userid} AND labelid =#{labelid}")
    Boolean weightDown(@Param("userid") int userid,@Param("labelid") int labelid);
}
